--离人诀于天涯
local lirenjueyutianya = fk.CreateSkill {
    name = "mcdh_lirenjueyutianya",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

lirenjueyutianya:addEffect(fk.Damaged,{
    can_trigger = function(self, event, target, player, data)
        local current = player.room.current
        return target == player and player:hasSkill(self) and current and not current.dead and not current:isNude()
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local current = room.current
        local getcardplayer = room:askToChoosePlayers(player, {
            targets = room:getOtherPlayers(current),
            min_num = 1,
            max_num = 1,
            prompt = "#mcdh_LRJYTY_choose",
            skill_name = self.name,
            cancelable = true
          })
        if #getcardplayer > 0 then
            self.cost_data = getcardplayer[1]
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local current = room.current
        local to = self.cost_data
        local card = room:askForCard(current, 1, 1, true, self.name, false, ".", "#mcdh_LRJYTY_choosecard")
        room:moveCardTo(card, Card.PlayerHand, to, fk.ReasonGive, self.name, nil, false, current)
        if current.id == player.id then
            player:drawCards(1, self.name)
        end
        room:setPlayerMark(to, "@mcdh_LRJYTY_prohitbit-turn", " ")
    end
})

lirenjueyutianya:addEffect('prohibit',{
    prohibit_use = function(self, player, card)
        return player:getMark("@mcdh_LRJYTY_prohitbit-turn") ~= 0
    end,
})

Fk:loadTranslationTable {
    ["mcdh_lirenjueyutianya"] = "扬镳",
    [":mcdh_LRJYTY"] = "『离人诀于天涯』<br>当你受到伤害后，你可以令当前回合角色将一张牌交给你选择的另一名角色，然后获得牌的角色本回合不能再使用牌，若你以此法失去牌，你摸一张牌。",
    ["@mcdh_LRJYTY_prohitbit-turn"] = "绝于天涯 禁止使用",
    ["#mcdh_LRJYTY_choose"] = "离人诀于天涯: 选择一名角色，令当前回合角色交给其一张牌，获得牌的角色本回合不能再使用牌",
    ["#mcdh_LRJYTY_choosecard"] = "离人诀于天涯: 选择一张牌交给德米特里指定的角色，获得牌的角色本回合不能再使用牌",
}

return lirenjueyutianya